package org.travel.app.mapper;

import org.apache.ibatis.annotations.Param;
import org.travel.app.entity.ConsumePoints;
import org.travel.app.entity.PointsTransactions;
import org.travel.app.entity.spots.Spots;
import org.travel.app.entity.spots.SpotsShopTicket;
import org.travel.app.entity.spots.SpotsTicketPackage;
import org.travel.app.entity.ticket.TicketStock;
import org.travel.app.entity.user.User;
import org.travel.app.entity.user.UserDiscountTicket;
import org.travel.app.entity.spots.SpotsTickets;
import org.travel.app.entity.ticket.TicketDiscount;
import org.travel.app.entity.ticket.TicketPackages;
import org.travel.app.entity.ticket.UserTicketDiscount;

import java.util.List;

/**
 * @author nmm
 * @date 2024-12-2024/12/19
 * @deriction njm......
 */
public interface TicketMapper {

    /**
     * 通过景点id查询景点票
     * @param spotsId
     * @return
     */
    List<SpotsTickets> getSpotsTicketById(@Param("spotsId") Integer spotsId);


    /**
     * 减景点票库存
     */
    void reduceStock(@Param("stockId") int stockId);


    /**
     * 通过景点id查询相关套餐
     * @param spotsId
     * @return
     */
    List<TicketPackages> getTicketPackagesBySpotsId(@Param("spotsId") int spotsId);

    /**
     * 统计套餐所用的景点票
     * @param package_id
     * @return
     */
    TicketStock countPackageTicket(@Param("packageId") int package_id);

    /**
     * 减套餐库存
     * @param ticketTypeId
     */
    void reducePackageStock(@Param("ticketTypeId") int ticketTypeId,@Param("reduceNum") int reduceNum);


    /**
     * 查询所有优惠券
     * @return
     */
    List<TicketDiscount>  getDiscountTicketList();


    /**
     * 查询优惠券(前端显示)
     * @return
     */
    List<Spots> getDistinctTicketDiscount();


    /**
     * 后台查询所有优惠券
     * @return
     */
    List<TicketDiscount>  getTicketDiscountsList(@Param("pageNum") int pageNum, @Param("pageSize") int pageSize);

    /**
     *
     * 判断用户是否有足够的积分兑换
     * @param transactions
     * @return
     */
    User ensureUserHasPoints(@Param("userTransaction") PointsTransactions transactions);


    /**
     * 添加优惠券
     *
     * @param ticketDiscount
     */
    void addTicketDiscount(UserTicketDiscount ticketDiscount);


    /**
     * 交易优惠券
     */
    void transactionTicket(@Param("userTransaction") PointsTransactions transactions);


    /**
     *  添加用户优惠交易记录(积分兑换优惠券)
     */
    void addUserTransactionTicket(@Param("transactionRecord") PointsTransactions transactions);

    /**
     * 记录用户所拥有的优惠券(第一次兑换)
     * @param
     */
    void addUserHasTicket(@Param("userTickets")PointsTransactions transactions);

    /**
     * 判断是否有兑换相同的优惠券(如果有则执行数量添加，没有则执行addUserHasTicket)
     */
    Integer    hasDiscountTicket(@Param("transaction") PointsTransactions transactions);

    /**
     * 用户兑换优惠券(第二次兑换)
     * @param transactions
     */
    void userTransactionTicket(@Param("ticketTransaction") PointsTransactions transactions);


    /**
     * 查询用户所拥有的优惠券
     * @return
     */
    List<UserTicketDiscount> getUserHasTicketList(@Param("userId") int userId);


    /**
     * 用户使用优惠券
     * @param userDiscountTicket
     */
    void userUsingTicket(@Param("userDiscountTicket") UserDiscountTicket userDiscountTicket);

    /**
     * 用户消费随机赠送积分(用于成功生成订单之后)
     */
    void addUserPoint(@Param("consumeMsg") ConsumePoints consumePoints);


    /**
     * 查询在售景点票
     * @param pageNum
     * @param pageSize
     * @return
     */
    List<SpotsShopTicket>  getSpotsShopTicketList(@Param("pageNum") int pageNum,@Param("pageSize")int pageSize);

    /***
     * 查询景点套餐
     * @param pageNum
     * @param pageSize
     * @return
     */
     List<TicketPackages> getSpotsPackage(@Param("pageNum") int pageNum,@Param("pageSize")int pageSize);

    /**
     * 获取前端显示景点套餐
     * @return
     */
    List<TicketPackages>  getCustomSpotsPackage();


    /**
     * 用于添加优惠券显示套餐
     * @return
     */
    List<TicketPackages> getSpotsPackages();

    /**
     * 通过可选票数查询套餐类型
     * @param packageId
     * @return
     */
     int   getSpotsPackageChoice(@Param("packageId")int packageId);

    /**
     * 返回不同票种的类型id
     * @param packageId
     * @return
     */
     List<Integer> getSpotsPackageTicketTypeId(@Param("packageId") int packageId);


    /**
     * 减不同票种套餐的库存
     */
    void  reduceDifferentTicketPackage(@Param("ticketTypesId") List<Integer> ticketTypesId);


    /**
     * 添加在售景点票
     * @param spotsTickets
     */
    void  addSpotsTicket(SpotsTickets spotsTickets);

    /**
     * 添加景点套餐
     * @param ticketPackages
     */
    void addTicketPackage(TicketPackages ticketPackages);


    /**
     * 删除景点套餐
     * @param packageId
     */
    void delTicketPackage(@Param("packageId") int packageId);

    /**
     * 添加景点套餐管理
     * @param list
     */
    void  addSpotsTicketPackage(List<SpotsTicketPackage > list);


    /**
     * 添加套餐景点关联
     * @param spotsId
     * @param packageId
     */
    void  addPackSpots(@Param("spotsId") int[] spotsId,@Param("packageId") int packageId);
}